var re_btn = document.querySelector('.re_btn');
re_btn.onclick = function () {

    //1.创建ajax对象
    var xhr = null;
    try {
        xhr = new XMLHttpRequest();
    } catch (error) {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    //2.发送请求
    xhr.open("post", "http://localhost:8086/users/", true);
    //告诉服务器发送的是一个什么
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
    //3.调用send
    xhr.send("username=" + username1 + "&password=" + password1);
    //4.等待数据响应
    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            //判断本次下载的状态码都是多少
            if (xhr.status == 200) {
                console.log(xhr.responseText);
                if (xhr.responseText) {
                    alert("恭喜你注册成功")
                } else {
                    alert("注册失败")
                }
            } else {
                alert("Error:" + xhr.status);
            }
        }
    }
}


